import { reactive, toRefs } from 'vue'
import { Point3D } from '../components/type/GeoType'

export interface PositionInfo {
    scale: number
    center: Point3D
}

/**
 * @ClassName MapInfoCom
 * @Description 地图基础信息组件交互
 * @Author xuyizhuo
 * @Date 2023/12/11 21:27
 */
export default () => {
    const mapInfoData = reactive<{
        scale: number
        center: {
            x: number
            y: number
            z: number
        }
        drawingNumber: string
    }>({
        scale: 0,
        center: {
            x: 0,
            y: 0,
            z: 0,
        },
        drawingNumber: '审图号：GS（2022）4210 号',
    })

    // 更新位置信息
    const updatePosition = (positionInfo: PositionInfo) => {
        // console.log('positionInfo', positionInfo)
        const { scale, center } = positionInfo
        mapInfoData.scale = scale
        mapInfoData.center = center
    }

    return {
        ...toRefs(mapInfoData), // 地图中心点信息
        updatePosition, // 更新地图中心点信息
    }
}
